<!DOCTYPE html>
<html ng-app="nuaaim">

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<title></title>
		<link href="css/mui.min.css" rel="stylesheet" />
		<link href="css/style.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="css/bootstrap.min.css" />
		<link rel="stylesheet" href="css/bootstrap-treeview.css" />
		<link rel="stylesheet" href="css/font-awesome.min93e3.css" />
		<script src="http://cdn.ronghub.com/RongIMLib-2.2.4.min.js"></script>
		<script type="text/javascript" src="js/angular.js"></script>
		<script type="text/javascript" src="js/IMchat.js"></script>
		<script type="text/javascript" src="js/mui.min.js"></script>
		<script type="text/javascript" src="js/app.js"></script>
		<script type="text/javascript" src="js/jquery-1.11.1.min.js"></script>
		<script type="text/javascript" src="js/bootstrap-treeview.js"></script>
		<script type="text/javascript" src="js/treeview-demo2.min.js"></script>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<h1 class="mui-title">我的好友</h1>
		</header>
		<div class="mui-content">
			<div class="mui-input-row mui-search">
				<input id="userAccount" name="userAccount" type="search" onkeydown="search(event)" class="mui-input-clear" placeholder="搜索好友">
			</div>
			<div id="treeview" class="test"></div>
		</div>
		
	</body>
	<script>
		function search(e) {
			if(e.keyCode == 13) {
				var userAccount = $("#userAccount").val();
				$.get('http://hs.tunnel.javano.cn/search/' + userAccount, function(data) {
					if(data.username != null) {
						//查询分组
						var content = data.account + "<br/><input type='text' id='userGroup' name='group' placeholder='输入分组'/>"
						mui.confirm( content, data.username, ['取消', '添加'], function(e) {
							if(e.index == 1){
								var userAccount = app.getState().account;
								var userGroup = $("#userGroup").val();
								var url = "http://hs.tunnel.javano.cn/appendFriend";
								$.get(url,{
									userAccount : userAccount,
									targetAccount:data.account,
									userGroup:userGroup
								},function(result){
									mui.alert(result,'提示','关闭',function (e) {
									   getNodeData();//重新加载数据
									},'div')
								})
							}
						}, 'div')
					}else {
						mui.confirm('没有找到','提示',['取消','确认'],function (e) {
							e.index
						},'div')
					}
				})
			}

		}
	</script>

</html>